{itemplate 'public/header'}
<form action="./index.php" class="form-horizontal form-filter">
	{php echo tpl_form_filter_hidden('service/comment/list');}
	<input type="hidden" name="status" value="{$status}"/>
	<input type="hidden" name="reply" value="{$reply}"/>
	<input type="hidden" name="note" value="{$note}"/>
	<div class="form-group">
		<label class="col-xs-12 col-sm-3 col-md-2 control-label">审核状态</label>
		<div class="col-sm-9 col-xs-12">
			<div class="btn-group">
				<a href="{php echo ifilter_url('status:-1');}" class="btn {if $status == -1}btn-primary{else}btn-default{/if}">不限</a>
				<a href="{php echo ifilter_url('status:0');}" class="btn {if $status == 0}btn-primary{else}btn-default{/if}">待审核</a>
				<a href="{php echo ifilter_url('status:1');}" class="btn {if $status == 1}btn-primary{else}btn-default{/if}">审核通过</a>
				<a href="{php echo ifilter_url('status:2');}" class="btn {if $status == 2}btn-primary{else}btn-default{/if}">审核未通过</a>
			</div>
		</div>
	</div>
	<div class="form-group">
		<label class="col-xs-12 col-sm-3 col-md-2 control-label">评价管理</label>
		<div class="col-sm-9 col-xs-12">
			<div class="btn-group">
				<a href="{php echo ifilter_url('reply:-1');}" class="btn {if $reply == -1}btn-primary{else}btn-default{/if}">不限</a>
				<a href="{php echo ifilter_url('reply:0');}" class="btn {if $reply == 0}btn-primary{else}btn-default{/if}">未回复</a>
				<a href="{php echo ifilter_url('reply:1');}" class="btn {if $reply == 1}btn-primary{else}btn-default{/if}">已回复</a>
			</div>
		</div>
	</div>
	<div class="form-group">
		<label class="col-xs-12 col-sm-3 col-md-2 control-label">有无内容</label>
		<div class="col-sm-9 col-xs-12">
			<div class="btn-group">
				<a href="{php echo ifilter_url('note:-1');}" class="btn {if $note == -1}btn-primary{else}btn-default{/if}">不限</a>
				<a href="{php echo ifilter_url('note:1');}" class="btn {if $note == 1}btn-primary{else}btn-default{/if}">有内容</a>
			</div>
		</div>
	</div>
	<div class="form-group">
		<label class="col-xs-12 col-sm-3 col-md-2 control-label">司机评价</label>
		<div class="col-sm-9 col-xs-12">
			<div class="btn-group">
				<a href="{php echo ifilter_url('goods_quality:-1');}" class="btn {if $goods_quality == -1}btn-primary{else}btn-default{/if}">不限</a>
				<a href="{php echo ifilter_url('goods_quality:1');}" class="btn {if $goods_quality == 1}btn-primary{else}btn-default{/if}">一星</a>
				<a href="{php echo ifilter_url('goods_quality:2');}" class="btn {if $goods_quality == 2}btn-primary{else}btn-default{/if}">二星</a>
				<a href="{php echo ifilter_url('goods_quality:3');}" class="btn {if $goods_quality == 3}btn-primary{else}btn-default{/if}">三星</a>
				<a href="{php echo ifilter_url('goods_quality:4');}" class="btn {if $goods_quality == 4}btn-primary{else}btn-default{/if}">四星</a>
				<a href="{php echo ifilter_url('goods_quality:5');}" class="btn {if $goods_quality == 5}btn-primary{else}btn-default{/if}">五星</a>
			</div>
		</div>
	</div>
	<div class="form-group">
		<label class="col-xs-12 col-sm-3 col-md-2 control-label">平台服务</label>
		<div class="col-sm-9 col-xs-12">
			<div class="btn-group">
				<a href="{php echo ifilter_url('delivery_service:-1');}" class="btn {if $delivery_service == -1}btn-primary{else}btn-default{/if}">不限</a>
				<a href="{php echo ifilter_url('delivery_service:1');}" class="btn {if $delivery_service == 1}btn-primary{else}btn-default{/if}">一星</a>
				<a href="{php echo ifilter_url('delivery_service:2');}" class="btn {if $delivery_service == 2}btn-primary{else}btn-default{/if}">二星</a>
				<a href="{php echo ifilter_url('delivery_service:3');}" class="btn {if $delivery_service == 3}btn-primary{else}btn-default{/if}">三星</a>
				<a href="{php echo ifilter_url('delivery_service:4');}" class="btn {if $delivery_service == 4}btn-primary{else}btn-default{/if}">四星</a>
				<a href="{php echo ifilter_url('delivery_service:5');}" class="btn {if $delivery_service == 5}btn-primary{else}btn-default{/if}">五星</a>
			</div>
		</div>
	</div>
	{if check_plugin_perm('ordergrant') && get_plugin_config('ordergrant.share.status')}
		<div class="form-group">
			<label class="col-xs-12 col-sm-3 col-md-2 control-label">是否分享</label>
			<div class="col-sm-9 col-xs-12">
				<div class="btn-group">
					<a href="{php echo ifilter_url('is_share:-1');}" class="btn {if $is_share == -1}btn-primary{else}btn-default{/if}">不限</a>
					<a href="{php echo ifilter_url('is_share:0');}" class="btn {if $is_share == 0}btn-primary{else}btn-default{/if}">未分享</a>
					<a href="{php echo ifilter_url('is_share:1');}" class="btn {if $is_share == 1}btn-primary{else}btn-default{/if}">已分享</a>
				</div>
			</div>
		</div>
	{/if}
	<div class="form-group form-inline">
		<label class="col-xs-12 col-sm-3 col-md-2 control-label">其他</label>
		<div class="col-sm-9 col-xs-12">
			<div class="js-daterange pull-left" data-form=".form-filter">
				{php echo tpl_form_field_daterange('addtime', array('start' => date('Y-m-d', $starttime), 'end' => date('Y-m-d', $endtime)));}
			</div>
			{if $_W['is_agent']}
				<select name="agentid" class="select2 js-select2 form-control width-130" style="margin: 2px 0 0 5px;">
					<option value="0">选择代理区域</option>
					{loop $_W['agents'] $agent}
						<option value="{$agent['id']}" {if $agentid == $agent['id']}selected{/if}>{$agent['area']}</option>
					{/loop}
				</select>
			{/if}
			<select name="sid" class="form-control select2 js-select2 width-130" id="select-sid" style="margin: 2px 0 0 5px;">
				<option value="0" {if !$sid}selected{/if}>全部线路</option>
				{loop $stores $store}
					<option value="{$store['id']}" {if $store['id'] == $sid}selected{/if}>{$store['title']}</option>
				{/loop}
			</select>
		</div>
	</div>
</form>
<form action="" class="form-table form" method="post">
	{if !empty($comments)}
		<div class="panel panel-comment">
			<div class="panel-body">
				{loop $comments $comment}
					<div class="comment-item clearfix">
						<div class="col-sm-2 col-md-2 col-lg-2 comment-item-left">
							<div class="customer-name">{$comment['mobile']}</div>
							<div class="store-title">{$stores[$comment['sid']]['title']}</div>
							<div class="seller">司机评价
								<?php
									for($i = 0; $i < $comment['goods_quality']; $i++) {
										echo '<span><i class="fa fa-star star light"></i></span> ';
									}
									for($i = $comment['goods_quality']; $i < 5; $i++) {
										echo '<span><i class="fa fa-star star"></i></span> ';
									}
								?>
							</div>
							<div class="delivery">平台服务
								<?php
									for($i = 0; $i < $comment['delivery_service']; $i++) {
										echo '<span><i class="fa fa-star star light"></i></span> ';
									}
									for($i = $comment['delivery_service']; $i < 5; $i++) {
										echo '<span><i class="fa fa-star star"></i></span> ';
									}
								?>
							</div>
							<div class="merit">综合评价：{$comment['score']}星</div>
							<span class="delivery-time btn-gray hide">41分钟送达</span>
						</div>
						<div class="col-sm-10 col-md-10 col-lg-10 comment-item-right">
							<div class="comment-date">
								{php echo date('Y-m-d H:i', $comment['addtime'])}
								&nbsp;
								{if $comment['status'] == 1}
									<span class="tag tag-success">审核通过</span>
								{elseif $comment['status'] == 2}
									<span class="tag tag-danger">审核未通过</span>
								{else}
									<span class="tag tag-default">待审核</span>
								{/if}
								{if check_plugin_perm('ordergrant') && get_plugin_config('ordergrant.share.status')}
									{if $comment['is_share'] == 1}
										<span class="tag tag-success">已分享</span>
									{else}
										<span class="tag tag-danger">未分享</span>
									{/if}
								{/if}
								<a href="{php echo iurl('order/takeout/detail', array('id' => $comment['oid']));}" target="_blank" class="pull-right check-order greenest">查看订单 <b class="fa fa-angle-right"></b></a>
							</div>
							<div class="comment-main">
								<div class="customer-comment">{if !empty($comment['note'])}{$comment['note']}{else}该用户没有填写评价内容{/if}</div>
								<div class="comment-img">
									{loop $comment['thumbs'] $thumb}
										<a href="{php echo tomedia($thumb)}" target="_blank"><img src="{php echo tomedia($thumb)}" alt=""></a>
									{/loop}
								</div>
								<div class="seller-comment clearfix grayest">
									{if !empty($comment['data']['good'])}
										<div class="pull-left seller-comment-goods">
											<b class="fa fa-thumbs-o-up"></b>
											{loop $comment['data']['good'] $good}
												<span>{$good}</span>
											{/loop}
										</div>
									{/if}
									{if !empty($comment['data']['bad'])}
										<div class="pull-left seller-comment-delivery">
											<b class="fa fa-thumbs-o-down"></b>
											<div class="comment-favor-oppose">
												<i class="icon favor"></i>
												{loop $comment['data']['bad'] $bad}
													<span>{$bad}</span>
												{/loop}
											</div>
										</div>
									{/if}
								</div>
								<a href="javascript:;" class="reply greenest" onclick="$(this).next('.reply-area').slideDown();"><b class="fa fa-comment-o"></b>回复</a>
								<div class="reply-area" {if !empty($comment['replytime'])}style="display:block"{/if}>
									<div class="reply-list">
										<div><span class="grayest">车主回复：</span></div>
										{if !empty($comment['replytime'])}
											<span class="grayest">{php echo date('Y-m-d H:i', $comment['replytime'])}</span>
										{/if}
									</div>
									<div class="input-area">
										<textarea class="form-control" placeholder="限300字符，请勿恶意回复，一经查实将严肃处理">{$comment['reply']}</textarea>
										<a href="javascript:;" class="btn btn-primary btn-reply" data-id="{$comment['oid']}">回复</a>
										{if empty($comment['replytime'])}
											<a href="javascript:;" class="btn btn-default" onclick="$(this).parents('.reply-area').slideUp();">取消</a>
										{/if}
										<a href="{php echo iurl('service/comment/status', array('id' => $comment['id'], 'status' => 1))}" class="btn btn-success js-post">审核通过</a>
										<a href="{php echo iurl('service/comment/status', array('id' => $comment['id'], 'status' => 2))}" class="btn btn-danger js-post">未通过</a>
										{if check_plugin_perm('ordergrant') && get_plugin_config('ordergrant.share.status')}
											{if $comment['is_share'] == 1}
												<a href="{php echo iurl('service/comment/share', array('id' => $comment['id'], 'is_share' => 0))}" class="btn btn-info js-post" data-confirm="确定要取消分享吗?">取消分享</a>
											{else}
												<a href="{php echo iurl('service/comment/share', array('id' => $comment['id'], 'is_share' => 1))}" class="btn btn-warning js-post" data-confirm="确定要分享吗?">分享</a>
											{/if}
										{/if}
									</div>
									<div class="arrow"></div>
								</div>
							</div>
						</div>
					</div>
				{/loop}
				{$pager}
			</div>
		</div>
	{else}
		<div class="no-result">
			<p>还没有相关数据</p>
		</div>
	{/if}
</form>
<script>
$(function(){
	$(document).on('click', '.comment-item .btn-reply', function(){
		var id = $(this).data('id');
		var reply = $(this).prev('textarea').val();
		if(!reply) {
			Notify.info('回复内容不能为空');
			return false;
		}
		$(this).attr('disabled', true);
		$.post("{php echo iurl('service/comment/reply')}", {id: id, reply: reply}, function(data){
			$(this).attr('disabled', false);
			var result = $.parseJSON(data);
			if(!result.message.errno) {
				Notify.success('回复成功', location.href);
			} else {
				Notify.error(result.message.message);
			}
		});
	});
});
</script>
{itemplate 'public/footer'}
